﻿#pragma once
#include "Common.h"
#include <QObject>
#include <QLabel>
#include <QMutex>

class imageView : public QLabel
{
	//Q_OBJECT
public:
	explicit imageView(QWidget* parent = 0);
	void setImage(QImage image);
	void setLable(QString lable);
	QImage getImage();
	void clear();
protected:
	void paintEvent(QPaintEvent* event);                        //QPaint画图
	void wheelEvent(QWheelEvent* event) override;               //鼠标滚轮滚动
	void mousePressEvent(QMouseEvent* event) override;          //鼠标摁下
	void mouseDoubleClickEvent(QMouseEvent* event) override;    //双击，还原图像大小
	void mouseMoveEvent(QMouseEvent* event) override;           //鼠标松开
	void mouseReleaseEvent(QMouseEvent* event) override;        //鼠标发射事件

private:
	void OnZoomInImage();       //图片放大
	void OnZoomOutImage();      //图片缩小
	void OnPresetImage();       //图片还原

private:
	QMutex						m_Mutex;
	QImage						m_Image;           //显示的图片
	QString						m_strLable;

	qreal ZoomValue = 1.0;  //鼠标缩放值
	int XPtInterval = 0;    //平移X轴的值
	int YPtInterval = 0;    //平移Y轴的值
	QPoint OldPos;          //旧的鼠标位置
	bool Pressed = false;   //鼠标是否被摁压
};




